package edu.gatech.ors.mrsim.io.conf;

public class BasicLoader implements ConfigurationClassLoader {

	@Override
	public Class<?> loadClass(String key, PropertiesConfiguration from) throws ClassNotFoundException {
		if (key != null && !from.containsKey(key))
			return null;
		return Class.forName(from.getProperty(key));
	}

	@Override
	public Class<?>[] loadClasses(String key, PropertiesConfiguration from) throws ClassNotFoundException {
		if (key != null && !from.containsKey(key))
			return null;
		String[] names = from.getStrings(key);
		if (names != null) {
			Class<?>[] classes = new Class<?>[names.length];
			for (int i = 0; i < names.length; i++)
				classes[i] = Class.forName(names[i]);
			return classes;
		}
		return null;
	}
}
